<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<h1>This is my first Ajax</h1>
<div id="response"></div>
<script >

    const xmlObj = new XMLHttpRequest();

    xmlObj.open("POST","http://127.0.0.1:8889",true);
    xmlObj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlObj.send("This is just a test");

    xmlObj.onreadystatechange = function(){
        console.log(111);
        if(xmlObj.readyState===4&&xmlObj.status===200){
            document.getElementById("response").innerHTML = xmlObj.responseText;
        }
    };


    console.log(xmlObj.responseText);


</script>
</body>
</html>